import React from 'react';
import ReactDOM from 'react-dom';
import { hashHistory } from 'react-router';
import ReactScrollbar from 'react-scrollbar-js';
require("./home.css");

// Tab选择器组件，只有HR才有
class TabsControl extends React.Component{
    constructor() {
        super();
        this.state={currentIndex : 0};
    }

    check_tittle_index(index){
        return index===this.state.currentIndex ? "Query_tittle Query_active" : "Query_tittle";
    }

    check_item_index(index){
        return index===this.state.currentIndex ? "Query_item Query_show" : "Query_item";
    }

    render(){
        return(
            <div>
                <div className="Query_tittle_wrap">
                    { React.Children.map( this.props.children , (element,index) => {
                        return(
                            <div onClick={ () => { this.setState({currentIndex : index}) } } className={ this.check_tittle_index(index) }>{ element.props.name }</div>
                        );
                    }) }
                    <hr/>
                </div>
                <div className="Query_item_wrap">
                    {React.Children.map(this.props.children,(element,index)=>{
                        return(
                            <div className={ this.check_item_index(index) }>{ element }</div>
                        );
                    })}
                </div>
            </div>
        );
    }
}

// 查询本公司
class ThisCompany extends React.Component {
    constructor() {
        super();
        const userSessionStorage = JSON.parse(window.sessionStorage.getItem('userStorage'));
        console.log(userSessionStorage);
        this.state = {
            loginID : userSessionStorage.user_id,
            loginCompanyID : userSessionStorage.company_id,
            queryID : '',
            query : []
        };
    }

    // 根据输入的职信号查询到该用户，本公司的可以添加奖惩，移除本公司
    handleSubmit(e){
        e.preventDefault();
        console.log("bb"+this.state.queryID+"kk");
        this.FetchData();
    }

    //将输入的user_id，company_id提交到服务器然后setState到query里面
    FetchData(){
        fetch("http://121.196.202.247:1010/select_user/?format=json", {
            method: "POST",
            headers: {
                'Accept': 'application/json',
                "Content-Type": "application/json; charset=utf-8"
            },
            body: JSON.stringify({
                user_id: this.state.queryID,
                company_id: this.state.loginCompanyID,
            })
        }) .then((response) => response.json())
            .then((responseText) => {
                this.setState({query:responseText});
                console.log(JSON.stringify(this.state.query));
                console.log("查询获得本公司的所以员工信息"+JSON.stringify(responseText));
            }).catch((error) => {alert(error+"连接职信服务器失败，请查看网络连接状态并刷新页面！")});
    }

    handleChange(e){
        this.setState({queryID: e.target.value});
    }

    render() {
        const style = {
            scroll:{
                width: "480px",
                height: "300px",
            }
        };

        return (
            <div>
                <form className="query_find" onSubmit={function (e) {this.handleSubmit(e)}.bind(this)}>
                    <input type="text" className="query_text" placeholder="请输入要查询的员工职信号" value={this.state.queryID} onChange={this.handleChange.bind(this)}/>
                    <input type="submit" value="搜索" className="query_btn"/>
                </form>
                <br/><br/>
                <div className="query_info">
                    <ReactScrollbar style={style.scroll}>
                        <div>
                            <hr/>
                                <SelfCompanyData fetch={this.state.query}/>
                            <hr/>
                        </div>
                    </ReactScrollbar>
                </div>
            </div>
        );
    }
}

// scrollBar里面，本公司人员信息初始化加载
class SelfCompanyData extends React.Component{

    constructor(props){
        super(props);
        const userSessionStorage = JSON.parse(window.sessionStorage.getItem('userStorage'));
        console.log(userSessionStorage);
        this.state={
            loginID : userSessionStorage.user_id,
            loginCompanyID : userSessionStorage.company_id,
            queryUser: [],
        }
    }

    // 在组件渲染之前预加载数据
    componentWillMount(){
        this.LoadData();
    }

    // 一开始获得本公司的所有员工信息，将获得的信息存到query数组里面
    LoadData(){
        fetch("http://121.196.202.247:1010/select_user/?format=json", {
            method: "POST",
            headers: {
                'Accept': 'application/json',
                "Content-Type": "application/json; charset=utf-8"
            },
            body: JSON.stringify({
                company_id: this.state.loginCompanyID,
            })
        }) .then((response) => response.json())
            .then((responseText) => {
                this.setState({queryUser : responseText});
                console.log("111"+this.state.queryUser);
                console.log("2222"+JSON.stringify(this.state.queryUser));
            }).catch((error) => {alert(error+"连接职信服务器失败，请查看网络连接状态并刷新页面！")});
    }

    // 个人简介按钮，传值跳转页面
    intro(e){
        e.preventDefault();
        console.log(e.target.getAttribute('content'));
        hashHistory.push({
            pathname: '/home_query_hr_intro',
            query: {
                selectUser:e.target.getAttribute('content'),
            },
        })
    }

    // 设置岗位按钮，传值跳转
    setJob(e){
        e.preventDefault();
        console.log(e.target.getAttribute('content'));
        hashHistory.push({
            pathname: '/home_query_hr_setJob',
            query: {
                selectUser:e.target.getAttribute('content'),
            },
        })
    }

    // 添加奖惩按钮，传值跳转页面
    addRP(e){
        e.preventDefault();
        console.log(e.target.getAttribute('content'));
        hashHistory.push({
            pathname: '/home_query_hr_addRP',
            query: {
                selectUser:e.target.getAttribute('content'),
            },
        })
    }

    // 加入黑名单按钮，传值跳转页面
    addBlack(e){
        e.preventDefault();
        console.log(e.target.getAttribute('content'));
        hashHistory.push({
            pathname: '/home_query_hr_addBlack',
            query: {
                selectUser:e.target.getAttribute('content'),
            },
        })
    }

    // 正常离职，移出公司不用写原因
    deleteUser(userID){
        console.log(userID);

        // 弹出确认框，确定返回true，取消返回false
        let is_Delete = confirm("是否确认将该员工正常移出公司，若确定请选择“确定”，反之选“取消”。");
        if(is_Delete == true){
            fetch("http://121.196.202.247:1010/prize_punish/?li_zhi=3&user_id="+userID, {
                method: "GET",
                headers: {
                    'Accept': 'application/json',
                    "Content-Type": "application/json; charset=utf-8"
                },
            }) .then((response) => response.json())
                .then((responseText) => {
                    console.log("33333"+responseText);
                    console.log("33333"+JSON.stringify(responseText));
                    alert("将该员工移出公司成功！");
                }).catch((error) => {alert(error+"连接职信服务器失败，请查看网络连接状态并刷新页面！")}
            );
        }else{}
    }

    render(){
        // 初加载公司界面
        let body = [];
        if (this.state.queryUser.length == 0){
            body.push(<p>正在加载......</p>);
        }else{
            for(let i=0;i<this.state.queryUser.length;i++) {
                if(this.state.queryUser[i].user_id != this.state.loginID){
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{this.state.queryUser[i].user_name}&nbsp;&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                    <p>身份证号：{this.state.queryUser[i].user_id_card}</p>
                                    <p>手机号：{this.state.queryUser[i].user_phone}</p>
                                </div>
                                <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.setJob(e)}.bind(this)}className="setJob">设置岗位</button>
                                <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.addRP(e)}.bind(this)} className="addRP">添加奖惩</button><br/>
                                <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.addBlack(e)}.bind(this)} className="addBlack">加入黑名单</button>
                                <input type="button" value="移出公司" className="deleteUser" onClick={function (e) {this.deleteUser(this.state.queryUser[i].user_id)}.bind(this)}/><br/>
                            </div>
                            <hr/>
                        </div>
                    );
                }else{
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{this.state.queryUser[i].user_name}&nbsp;&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                    <p>身份证号：{this.state.queryUser[i].user_id_card}</p>
                                    <p>手机号：{this.state.queryUser[i].user_phone}</p>
                                </div>
                                <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                            </div>
                            <hr/>
                        </div>
                    );
                }
            }
        }

        // 父组件的query[]数组
        var getFetch = this.props.fetch;
        console.log("vvvv1"+JSON.stringify(getFetch));
        console.log(getFetch.length);

        // 服务端有1条数据返回有以下四种情况：
        if(getFetch.length == 1){
            console.log(getFetch[0].user_id);

            // 1.系统中有这个职信号，但本公司没有
            if(getFetch[0].user_id == 'fail'){
                body.length = 0;
                body.push(
                    <div>
                        <hr/>
                        <div className="query_user">
                            <p>当前公司并没有该员工！请检查输入的职信号是否正确。</p>
                        </div>
                        <hr/>
                    </div>
                );
            }

            // 2.当前搜索的人不在系统中，没有该职信号
            else if(getFetch[0].user_id == 'this user id not exist'){
                body.length = 0;
                body.push(
                    <div>
                        <hr/>
                        <div className="query_user">
                            <p>抱歉，系统中并不存在该职信号，请检查输入的职信号是否正确。</p>
                        </div>
                        <hr/>
                    </div>
                );
            }

            // 3.搜索的这个人是在本公司里，且就是当前HR本人
            else if(getFetch[0].user_id == this.state.loginID){
                body.length = 0;
                body.push(
                    <div>
                        <hr/>
                        <div className="query_user">
                            <div className="query_user_photo">
                                <div className="user_photo_img">
                                    <img src={getFetch[0].user_image} alt="头像"/>
                                </div>
                            </div>
                            <div className="query_user_info">
                                <p>姓名：{getFetch[0].user_name}&nbsp;&nbsp;职信号：{getFetch[0].user_id}</p>
                                <p>身份证号：{getFetch[0].user_id_card}</p>
                                <p>手机号：{getFetch[0].user_phone}</p>
                            </div>
                            <button content={getFetch[0].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                        </div>
                        <hr/>
                    </div>
                );
            }

            // 4.搜索的这个人是在本公司里，且不是当前HR本人
            else{
                body.length = 0;
                body.push(
                    <div>
                        <hr/>
                        <div className="query_user">
                            <div className="query_user_photo">
                                <div className="user_photo_img">
                                    <img src={getFetch[0].user_image} alt="头像"/>
                                </div>
                            </div>
                            <div className="query_user_info">
                                <p>姓名：{getFetch[0].user_name}&nbsp;&nbsp;职信号：{getFetch[0].user_id}</p>
                                <p>身份证号：{getFetch[0].user_id_card}</p>
                                <p>手机号：{getFetch[0].user_phone}</p>
                            </div>
                            <button content={getFetch[0].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                            <button content={getFetch[0].user_id} onClick={function (e) {this.setJob(e)}.bind(this)}className="setJob">设置岗位</button>
                            <button content={getFetch[0].user_id} onClick={function (e) {this.addRP(e)}.bind(this)} className="addRP">添加奖惩</button><br/>
                            <button content={getFetch[0].user_id} onClick={function (e) {this.addBlack(e)}.bind(this)} className="addBlack">加入黑名单</button>
                            <input type="button" value="移出公司" className="deleteUser" onClick={function (e) {this.deleteUser(getFetch[0].user_id)}.bind(this)}/>
                        </div>
                        <hr/>
                    </div>
                );
            }
        }

        // 提交空可能返回多条
        else if(getFetch.length > 1){
            body.length = 0;
            for(let i=0;i <getFetch.length; i++) {
                if (getFetch[i].user_id != this.state.loginID) {
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{getFetch[i].user_name}&nbsp;&nbsp;职信号：{getFetch[i].user_id}</p>
                                    <p>身份证号：{getFetch[i].user_id_card}</p>
                                    <p>手机号：{getFetch[i].user_phone}</p>
                                </div>
                                <button content={getFetch[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                <button content={getFetch[i].user_id} onClick={function (e) {this.setJob(e)}.bind(this)}className="setJob">设置岗位</button>
                                <button content={getFetch[i].user_id} onClick={function (e) {this.addRP(e)}.bind(this)} className="addRP">添加奖惩</button><br/>
                                <button content={getFetch[i].user_id} onClick={function (e) {this.addBlack(e)}.bind(this)} className="addBlack">加入黑名单</button>
                                <input type="button" value="移出公司" className="deleteUser" onClick={function (e) {this.deleteUser(e)}.bind(this)}/>
                            </div>
                            <hr/>
                        </div>
                    );
                }else{
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{getFetch[i].user_name}&nbsp;&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                    <p>身份证号：{getFetch[i].user_id_card}</p>
                                    <p>手机号：{getFetch[i].user_phone}</p>
                                </div>
                                <button content={getFetch[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                            </div>
                            <hr/>
                        </div>
                    );
                }
            }
        }else{}

        return (
            <div>
                <hr/>
                {body}
                <hr/>
            </div>
        );
    }
}







// 查询所有人
class AllPeople extends React.Component {
    constructor() {
        super();
        this.state = {
            queryID : '',
            query : []
        };
    }

    // 根据输入的职信号查询到该用户，可以查看，可以将company_id的用户加入到本公司
    handleSubmit(e){
        e.preventDefault();
        console.log("bbb"+this.state.queryID+"kkk");
        this.FetchData();
    }

    //将输入的user_id提交到服务器然后setState到query里面
    FetchData(){
        fetch("http://121.196.202.247:1010/select_user/?user_id="+this.state.queryID, {
            method: "GET",
            headers: {
                'Accept': 'application/json',
                "Content-Type": "application/json; charset=utf-8"
            },
        }) .then((response) => response.json())
            .then((responseText) => {
                console.log(this.state.queryID);
                this.setState({query:responseText});
                console.log(JSON.stringify(this.state.query));
                console.log("查询获得本公司的所以员工信息"+JSON.stringify(responseText));
            }).catch((error) => {alert(error+"连接职信服务器失败，请查看网络连接状态并刷新页面！")});
    }

    handleChange(e){
        this.setState({queryID: e.target.value});
    }

    render() {

        const style = {
            scroll:{
                width: "480px",
                height: "300px",
            }
        };

        return (
            <div>
                <form className="query_find" onSubmit={function (e) {this.handleSubmit(e)}.bind(this)} ref="allPeopleForm">
                    <input type="text" className="query_text" placeholder="请输入要查询的用户职信号" value={this.state.queryID} onChange={this.handleChange.bind(this)} ref="queryAllPeople"/>
                    <input type="submit" value="搜索" className="query_btn"/>
                </form>
                <br/><br/>
                <div className="query_info">
                    <ReactScrollbar style={style.scroll}>
                        <div>
                            <hr/>
                            <AllPeopleData fetch={this.state.query}/>
                            <hr/>
                        </div>
                    </ReactScrollbar>
                </div>
            </div>
        );
    }
}

// scrollBar里面，系统全部人员信息初始化加载
class AllPeopleData extends React.Component{

    constructor(props){
        super(props);
        const userSessionStorage = JSON.parse(window.sessionStorage.getItem('userStorage'));
        console.log(userSessionStorage);
        this.state={
            loginID : userSessionStorage.user_id,
            loginCompanyID : userSessionStorage.company_id,
            queryUser: []
        }
    }

    // 在组件渲染之前预加载数据
    componentWillMount(){
        this.LoadData();
    }

    // 一开始获得系统中的所有人的信息，将获得的信息转化为string存到query数组里面
    LoadData(){
        fetch("http://121.196.202.247:1010/select_user/?format=json", {
            method: "GET",
            headers: {
                'Accept': 'application/json',
                "Content-Type": "application/json; charset=utf-8"
            },
        }) .then((response) => response.json())
            .then((responseText) => {
                this.setState({queryUser : responseText});
                console.log("111"+this.state.queryUser);
                console.log("111"+this.state.queryUser.length);
                console.log("2222"+JSON.stringify(this.state.queryUser));
            }).catch((error) => {alert(error+"连接职信服务器失败，请查看网络连接状态并刷新页面！")});
    }
    intro(e){
        e.preventDefault();
        console.log(e.target.getAttribute('content'));
        hashHistory.push({
            pathname: '/home_query_hr_intro',
            query: {
                selectUser:e.target.getAttribute('content'),
            },
        })
    }

    addToCompany(userID){
        console.log(userID);
        const userSessionStorage = JSON.parse(window.sessionStorage.getItem('userStorage'));

        // 弹出确认框，确定返回true，取消返回false
        let is_Add = confirm("是否确认将该员工加入本公司，若确定请选择“确定”，反之选“取消”。");
        if(is_Add == true){
            fetch("http://121.196.202.247:1010/select_user/?user_id="+userID+"&company_id="+userSessionStorage.company_id, {
                method: "GET",
                headers: {
                    'Accept': 'application/json',
                    "Content-Type": "application/json; charset=utf-8"
                },
            }) .then((response) => response.json())
                .then((responseText) => {
                    console.log("33333"+responseText);
                    console.log("33333"+JSON.stringify(responseText));
                    alert("将该员工加入公司成功！");
                }).catch((error) => {alert(error+"连接职信服务器失败，请查看网络连接状态并刷新页面！")}
            );
        }
        else{}
    }

    render(){

        // 初加载所有人界面，情况分别为：1.系统黑名单 2.本公司员工 3.其它公司员工 4.普通用户非员工
        let body = [];
        if (this.state.queryUser.length == 0){
            body.push(<p>正在加载......</p>);
        }else{
            body.length = 0;
            for(let i=0;i<this.state.queryUser.length;i++) {
                if(this.state.queryUser[i].user_id != this.state.loginID){

                    // 1.系统黑名单
                    if(this.state.queryUser[i].black_state == 1){
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{this.state.queryUser[i].user_name}&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                        <p>身份证号：{this.state.queryUser[i].user_id_card}</p>
                                        <p>手机号：{this.state.queryUser[i].user_phone}</p>
                                    </div>
                                    <input type="button" className="queryBlack" value="已为系统黑名单" />&nbsp;&nbsp;
                                    <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                </div>
                                <hr/>
                            </div>
                        );
                    }

                    // 2.本公司员工
                    else if(this.state.queryUser[i].company_id == this.state.loginCompanyID){
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{this.state.queryUser[i].user_name}&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                        <p>身份证号：{this.state.queryUser[i].user_id_card}</p>
                                        <p>手机号：{this.state.queryUser[i].user_phone}</p>
                                    </div>
                                    <input type="button" className="queryThisUser" value="已为本公司员工" />&nbsp;&nbsp;
                                    <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                </div>
                                <hr/>
                            </div>
                        );
                    }

                    // 3.其它公司员工
                    else if(this.state.queryUser[i].company_id != this.state.loginCompanyID && this.state.queryUser[i].company_id != null && this.state.queryUser[i].company_id != 0){
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{this.state.queryUser[i].user_name}&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                        <p>身份证号：{this.state.queryUser[i].user_id_card}</p>
                                        <p>手机号：{this.state.queryUser[i].user_phone}</p>
                                    </div>
                                    <input type="button" className="queryOtherUser" value="已为其它公司员工" />
                                </div>
                                <hr/>
                            </div>
                        );
                    }

                    // 4.普通用户非员工
                    else{
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{this.state.queryUser[i].user_name}&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                        <p>身份证号：{this.state.queryUser[i].user_id_card}</p>
                                        <p>手机号：{this.state.queryUser[i].user_phone}</p>
                                    </div>
                                    <div>
                                        <input type="button" className="queryToAddUser" value="求职者" />&nbsp; &nbsp;
                                        <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                        <input type="button" className="queryToAdd" value="将其加入公司" onClick={function (e) {this.addToCompany(this.state.queryUser[i].user_id)}.bind(this)}/>
                                    </div>
                                </div>
                                <hr/>
                            </div>
                        );
                    }
                }else{
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={this.state.queryUser[i].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{this.state.queryUser[i].user_name}&nbsp;&nbsp;职信号：{this.state.queryUser[i].user_id}</p>
                                    <p>身份证号：{this.state.queryUser[i].user_id_card}</p>
                                    <p>手机号：{this.state.queryUser[i].user_phone}</p>
                                </div>
                                <button content={this.state.queryUser[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                            </div>
                            <hr/>
                        </div>
                    );
                }
            }
        }

        // 父组件的query[]数组
        var getFetch = this.props.fetch;
        console.log("vvvv1"+JSON.stringify(getFetch));
        console.log(getFetch.length);

        // 服务端有1条数据返回有以下三种情况：
        if(getFetch.length == 1){
            console.log(getFetch[0].user_id);

            // 1.当前搜索的人不在系统中，没有该职信号
            if(getFetch[0].user_id == 'this user id not exist!'){
                body.length = 0;
                body.push(
                    <div>
                        <hr/>
                        <div className="query_user">
                            <p>当前系统并没有该用户！请检查输入的职信号是否正确。</p>
                        </div>
                        <hr/>
                    </div>
                );
            }

            // 2.搜索的这个人就是当前HR本人
            else if(getFetch[0].user_id == this.state.loginID){
                body.length = 0;
                body.push(
                    <div>
                        <hr/>
                        <div className="query_user">
                            <div className="query_user_photo">
                                <div className="user_photo_img">
                                    <img src={getFetch[0].user_image} alt="头像"/>
                                </div>
                            </div>
                            <div className="query_user_info">
                                <p>姓名：{getFetch[0].user_name}&nbsp;&nbsp;职信号：{getFetch[0].user_id}</p>
                                <p>身份证号：{getFetch[0].user_id_card}</p>
                                <p>手机号：{getFetch[0].user_phone}</p>
                            </div>
                            <button content={getFetch[0].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                        </div>
                        <hr/>
                    </div>
                );
            }

            // 3.搜索的这个人是在系统里，且不是当前HR本人，内部情况同初加载，有4种
            else{
                body.length = 0;

                // 1.系统黑名单
                if(getFetch[0].black_state == 1){
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={getFetch[0].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{getFetch[0].user_name}&nbsp;&nbsp;职信号：{getFetch[0].user_id}</p>
                                    <p>身份证号：{getFetch[0].user_id_card}</p>
                                    <p>手机号：{getFetch[0].user_phone}</p>
                                </div>
                                <input type="button" className="queryBlack" value="已为系统黑名单" />&nbsp;&nbsp;
                                <button content={getFetch[0].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                            </div>
                            <hr/>
                        </div>
                    );
                }

                // 2.本公司员工
                else if(getFetch[0].company_id == this.state.loginCompanyID){
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                {/*<span>以下为本公司的员工：</span><br/>*/}
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={getFetch[0].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{getFetch[0].user_name}&nbsp;&nbsp;职信号：{getFetch[0].user_id}</p>
                                    <p>身份证号：{getFetch[0].user_id_card}</p>
                                    <p>手机号：{getFetch[0].user_phone}</p>
                                </div>
                                <input type="button" className="queryThisUser" value="已为本公司员工" />&nbsp;&nbsp;
                                <button content={getFetch[0].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                            </div>
                            <hr/>
                        </div>
                    );
                }

                // 3.其它公司员工
                else if(getFetch[0].company_id != this.state.loginCompanyID && getFetch[0].company_id != null){
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                {/*<span>以下为其它公司的黑名单：</span><br/>*/}
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={getFetch[0].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{getFetch[0].user_name}&nbsp;&nbsp;职信号：{getFetch[0].user_id}</p>
                                    <p>身份证号：{getFetch[0].user_id_card}</p>
                                    <p>手机号：{getFetch[0].user_phone}</p>
                                </div>
                                <input type="button" className="queryOtherUser" value="已为其它公司员工" />
                            </div>
                            <hr/>
                        </div>
                    );
                }

                // 4.普通用户非员工
                else{
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                {/*<span>以下为其它公司的黑名单：</span><br/>*/}
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={getFetch[0].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{getFetch[0].user_name}&nbsp;&nbsp;职信号：{getFetch[0].user_id}</p>
                                    <p>身份证号：{getFetch[0].user_id_card}</p>
                                    <p>手机号：{getFetch[0].user_phone}</p>
                                </div>
                                <input type="button" className="queryToAddUser" value="求职者" />&nbsp;&nbsp;
                                <button content={getFetch[0].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                <input type="button" className="queryToAdd" value="将其加入公司" onClick={function (e) {this.addToCompany(getFetch[0].user_id)}.bind(this)}/>
                            </div>
                            <hr/>
                        </div>
                    );
                }
            }
        }

        // 提交空可能返回多条
        else if(getFetch.length > 1){
            body.length = 0;
            for(let i=0;i <getFetch.length; i++) {
                if (getFetch[i].user_id != this.state.loginID) {
                    // 1.系统黑名单
                    if(getFetch[i].black_state == 1){
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    {/*<span>以下为系统的黑名单：</span><br/>*/}
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={getFetch[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{getFetch[i].user_name}&nbsp;&nbsp;职信号：{getFetch[i].user_id}</p>
                                        <p>身份证号：{getFetch[i].user_id_card}</p>
                                        <p>手机号：{getFetch[i].user_phone}</p>
                                    </div>
                                    <input type="button" className="queryBlack" value="已为系统黑名单" />&nbsp;&nbsp;
                                    <button content={getFetch[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                </div>
                                <hr/>
                            </div>
                        );
                    }

                    // 2.本公司员工
                    else if(getFetch[i].company_id == this.state.loginCompanyID){
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    {/*<span>以下为本公司的员工：</span><br/>*/}
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={getFetch[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{getFetch[i].user_name}&nbsp;&nbsp;职信号：{getFetch[i].user_id}</p>
                                        <p>身份证号：{getFetch[i].user_id_card}</p>
                                        <p>手机号：{getFetch[i].user_phone}</p>
                                    </div>
                                    <input type="button" className="queryThisUser" value="已为本公司员工" />&nbsp;&nbsp;
                                    <button content={getFetch[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                </div>
                                <hr/>
                            </div>
                        );
                    }

                    // 3.其它公司员工
                    else if(getFetch[i].company_id != this.state.loginCompanyID && getFetch[i].company_id != null){
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    {/*<span>以下为其它公司的黑名单：</span><br/>*/}
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={getFetch[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{getFetch[i].user_name}&nbsp;&nbsp;职信号：{getFetch[i].user_id}</p>
                                        <p>身份证号：{getFetch[i].user_id_card}</p>
                                        <p>手机号：{getFetch[i].user_phone}</p>
                                    </div>
                                    <input type="button" className="queryOtherUser" value="已为其它公司员工" />
                                </div>
                                <hr/>
                            </div>
                        );
                    }

                    // 4.普通用户非员工
                    else{
                        body.push(
                            <div>
                                <hr/>
                                <div className="query_user">
                                    {/*<span>以下为其它公司的黑名单：</span><br/>*/}
                                    <div className="query_user_photo">
                                        <div className="user_photo_img">
                                            <img src={getFetch[i].user_image} alt="头像"/>
                                        </div>
                                    </div>
                                    <div className="query_user_info">
                                        <p>姓名：{getFetch[i].user_name}&nbsp;&nbsp;职信号：{getFetch[i].user_id}</p>
                                        <p>身份证号：{getFetch[i].user_id_card}</p>
                                        <p>手机号：{getFetch[i].user_phone}</p>
                                    </div>
                                    <input type="button" className="queryToAddUser" value="求职者" />&nbsp;&nbsp;
                                    <button content={getFetch[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                                    <input type="button" className="queryToAdd" value="将其加入公司" onClick={function (e) {this.addToCompany(this.state.queryUser[i].user_id)}.bind(this)}/>
                                </div>
                                <hr/>
                            </div>
                        );
                    }
                }else{
                    body.push(
                        <div>
                            <hr/>
                            <div className="query_user">
                                <div className="query_user_photo">
                                    <div className="user_photo_img">
                                        <img src={getFetch[i].user_image} alt="头像"/>
                                    </div>
                                </div>
                                <div className="query_user_info">
                                    <p>姓名：{getFetch[i].user_name}&nbsp;&nbsp;职信号：{getFetch[i].user_id}</p>
                                    <p>身份证号：{getFetch[i].user_id_card}</p>
                                    <p>手机号：{getFetch[i].user_phone}</p>
                                </div>
                                <button content={getFetch[i].user_id} onClick={function (e) {this.intro(e)}.bind(this)} className="viewResume">个人简介</button>
                            </div>
                            <hr/>
                        </div>
                    );
                }
            }
        }else{}

        return (
            <div>
                <hr/>
                {body}
                <hr/>
            </div>
        );
    }
}

export default React.createClass({
    render() {
        return (
            <div className="query">
                <TabsControl>
                    <div name="本公司">
                        <ThisCompany/>
                    </div>
                    <div name="所有人">
                        <AllPeople/>
                    </div>
                </TabsControl>
            </div>
        );
    }
})